package com.tbeasy.financial.provider;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.net.Uri;
import android.provider.BaseColumns;

public final class DatabaseUtil {

	public static final String DB_NAME = "tbeasy.db";
	public static final String AUTHORITY = "com.tbeasydb.provider";

	public static final class TableCategory implements BaseColumns {

		public static final String TAB_NAME = "tab_category";
		public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/" + TAB_NAME);

		public static String CATEGORY_ID = "category_id";
		public static final String NAME = "name";
		public static final String PARENT_CATEGORY_ID = "parent_category_id";
		public static final String LAST_UPDATE_TIME = "last_update_time";
		public static final String ICON_NAME = "icon_name";
		public static final String ORDERED = "ordered";

		private TableCategory() {

		}

		public static final String DEFAULT_SORT_ORDER = ORDERED + " DESC";
	}

	public static final class TableTransaction implements BaseColumns {
		public static final String TAB_NAME = "tab_transaction";
		public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/" + TAB_NAME);

		public static String TRANSACTION_ID = "transaction_id";
		public static final String CREATE_TIME = "create_time";
		public static final String MODIFIED_TIME = "modified_time";
		public static final String TRADE_TIME = "trade_time";
		public static final String MEMO = "memo";
		public static final String TYPE = "type";
		public static final String CATEGORY_ID = "category_id";
		public static final String BUYER_MONEY = "buyer_money";
		public static final String LAST_UPDATE_TIME = "last_update_time";

		public static final String DEFAULT_SORT_ORDER = TRANSACTION_ID + " DESC";

		private TableTransaction() {

		}
	}

//	public static final class TableBudgetItem implements BaseColumns {
//		public static final String TAB_NAME = "tab_budget_item";
//		public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/" + TAB_NAME);
//
//		public static String BUDGET_ITEM_ID = "budget_item_id";
//		public static final String CATEGORY_ID = "category_id";
//		public static final String AMOUNT = "amount"; 
//		public static final String LAST_UPDATE_TIME = "last_update_time";
//
//		private TableBudgetItem() {
//
//		}
//	}
	
	public static SQLiteDatabase getWritableDatabase(Context context) {
		DatabaseHelper helper = new DatabaseHelper(context);
		return helper.getWritableDatabase();
	}
	
	public static SQLiteDatabase getReadableDatabase(Context context) {
		DatabaseHelper helper = new DatabaseHelper(context);
		return helper.getReadableDatabase();
	}

}